# coding: utf-8
import pandas
import service.quan_stat as stat
import DAO.stockDAO


##暂时设计stock类以待后续使用
class Stock():
        __code =""
        __startDate ='2010-08-20'
        __endDate = '2018-3-13'
        recordlist={}
        quant ={}

        def __init__(self, code, start,end):
            self.__code = code
            self.__startDate = start
            self.__endDate= end

        def get_code(self):
            return self.__code
        def set_code(self,code):
            self.__code= code
        def get_start_date(self):
            return self.__startDate
        def set_start_date(self,start_date):
            self.__code= start_date
        def get_end_date(self):
            return self.__endDate
        def set_end_date(self,end_date):
            self.__code= end_date

        def set_quant(self,quant):
            self.quant=quant
        def get_quant(self):
            return self.quant

a_stock=Stock('111111','2010-08-30','2018-03-20')

def query_quant(code,index,start_date,end_date):

    queryresult=DAO.stockDAO.query(code,index,start_date,end_date)
    result= stat.returnAllresult(queryresult['date_line'],queryresult['capital_line'],queryresult['return_line'],queryresult['index_line'],queryresult['indexreturn_line'])
    return result

if __name__ == '__main__':
    print(query_quant("000001.SZ","hs300","2018-02-20","2018-03-13"))